home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr40 / radserv.zip / RADMSG.C < prev    next >
C/C++ Source or Header  |  1995-01-24  |  3KB  |  111 lines

  1.  
  2. /*
  3.  * Sample code. These routines simply display the data received from
  4.  * VersaTrack in a text window. They can be adapted to
  5.  * actually use the data for controlling an external device.
  6.  */
  7.  
  8. #include "radextrn.h"
  9. #undef  CV
  10. #define CV                 2.998e5        /* speed of light constant Km/s */
  11.  
  12. extern radparam_t rigInfo;
  13. extern HWND rdhwnd;
  14.  
  15. /*
  16.  * These rotines will be called each time a valid message is received
  17.  */
  18.  
  19. void
  20. r_control(char *satname , double elevation,
  21.           double dist, double velo, double fopl)
  22. {
  23.     extern void rdisp_update(void);
  24.     double dp;
  25.  
  26.     if (rigInfo.radio.ra_rxcenter <= 0)
  27.         rigInfo.radio.ra_rxcenter = 145000; /* Unit is KHZ */
  28.         
  29.     dp = (-1 * velo) / 2.997e5;  /* approx. coefficient */
  30.     rigInfo.radio.ra_doppler = (int) (dp * rigInfo.radio.ra_rxcenter * 1000);
  31.  
  32.     if (rdhwnd)
  33.         rdisp_update();
  34.  
  35. #ifdef _DEBUG_
  36.     diag("%s: El %.1lf Range %.1lf Spd %3.4lf Doppler coef %+.4e loss %.1lf\n",
  37.         satname, elevation, dist, velo, dp, fopl);
  38. #endif /* _DEBUG_ */
  39.     /*
  40.      * Use the data to either send appropriate command to device, or
  41.      * accumulate, compute mean, average or median (if rate is too high)
  42.      * before issuing cmds to device.
  43.      */
  44. }
  45.     
  46. void
  47. r_interrupt(char *satname, char *reason)
  48. {
  49. #ifdef _DEBUG_
  50.     sprintf(tmpbuf,"+++ interrupt: '%s'\n", reason);
  51.     diag(tmpbuf);
  52. #endif /* _DEBUG_ */
  53.     /*
  54.      * Notify user. suspend device control.
  55.      */
  56. }
  57.  
  58. void
  59. r_init(char *satname, char *sitename, char *mode, int update)
  60. {
  61. #ifdef _DEBUG_
  62.     sprintf(tmpbuf,"+++ Initialize: '%s' from '%s' Mode %s Update %d sec.\n",
  63.         satname, sitename, mode, update);
  64.     diag(tmpbuf);
  65. #endif /* _DEBUG_ */
  66.     /*
  67.      * Proceed to determine server parameters, if a satellite/transponder/mode
  68.      * database is used, determine correct uplink/downlink. Issue cmds
  69.      * to radio to set frequency/mode.
  70.      * For a rotator, determine min/max limits of travel, stepping rate
  71.      * and skews for intertia compensation, start/stop latancies, etc.
  72.      * Some of these operations may need to be delayed until several
  73.      * movement samples have been accumulated.
  74.      */
  75. }
  76.  
  77. void
  78. r_end(HWND wid)
  79. {
  80. #ifdef _DEBUG_
  81.     diag("End Connection: Window ID = %x\n", wid);
  82. #endif /* _DEBUG_ */
  83.     /*
  84.      * Proceed to restore device status for device that is being controlled.
  85.      * For a rotator, it may be necessary to park both in AZ and EL.
  86.      * Notify user.
  87.      */
  88. }
  89.  
  90. void
  91. r_begin(HWND wid)
  92. {
  93. #ifdef _DEBUG_
  94.     diag("Begin Connection: Window ID = %x\n", wid);
  95. #endif /* _DEBUG_ */
  96.     /*
  97.      * Proceed to open the COM port to the device being controlled, etc.
  98.      * Get device status and initialize data structures and state information.
  99.      */
  100. }
  101.  
  102. void
  103. r_special(int code)
  104. {
  105. #ifdef _DEBUG_
  106.     sprintf(tmpbuf,"+++ received special cmd (%d)\n", code);
  107.     diag(tmpbuf);
  108.     /* NOT CURRENTLY USED */
  109. #endif /* _DEBUG_ */
  110. }
  111.